package com.example.flutter_base_widget

import android.app.AlertDialog
import android.content.Context
import android.os.Bundle
import com.baidu.mapapi.CoordType
import com.baidu.mapapi.SDKInitializer
import com.baidu.mapapi.map.BaiduMapOptions
import com.baidu.mapapi.map.MapView
import com.baidu.mapapi.map.TextureMapView
import com.example.flutter_base_widget.plugin.MyApplication
import com.example.flutter_base_widget.plugin.MyViewFactory
import com.example.flutter_base_widget.plugin.MyViewPlugin

import io.flutter.app.FlutterActivity
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {


  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)

    var option = BaiduMapOptions()

    var mapView = TextureMapView(this,option)


    MyViewPlugin.registerWith(this.registrarFor("com.myplugin.android"), mapView)



    var channel = MethodChannel(flutterView, "zl_call")
    channel.setMethodCallHandler { methodCall, result ->
      if(methodCall.method == "show"){
        var arg = methodCall.arguments
        show(flutterView.context,arg.toString())
        result.success("success")
      }
    }

  }

  fun show(context: Context, title: String){
    val msg = title
    AlertDialog.Builder(context)
            .setMessage(msg)
            .setTitle("测试提示")
            .setNeutralButton("取消", null)
            .create()
            .show()
  }
}
